home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / Temperature / CAboutDialog.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  3.4 KB  |  175 lines  |  [TEXT/CWIE]

  1. // CAboutDialog.cp -- dialog methods
  2.  
  3. #include "CAboutDialog.h"
  4.  
  5. #include <UEnvironment.h>
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LTabGroup.h>
  10. #include <LPushButton.h>
  11. #include <LAMPushButtonImp.h>
  12. #include <LGAPushButtonImp.h>
  13. #include <LStaticText.h>
  14. #include <LAMStaticTextImp.h>
  15. #include <LGAStaticTextImp.h>
  16. #include <CTextUtils.h>
  17.  
  18. #include "TemperatureCmds.h"
  19. #include <PP_Messages.h>
  20.  
  21.  
  22. #define PPob_AboutDialogID    202
  23. #define RidL_AboutDialogID    202
  24.  
  25. Boolean        CAboutDialog::sIsRegistered = false;
  26.  
  27. //----------
  28. CAboutDialog*        CAboutDialog::CreateAboutDialog (
  29.     LCommander*        inSuperCommander,
  30.     CommandT        inCommand)
  31. {
  32.     if (!sIsRegistered) {
  33.         RegisterClass ();
  34.     }
  35.     CAboutDialog*        dlog;
  36.     dlog = ((CAboutDialog *)LWindow::CreateWindow(PPob_AboutDialogID, inSuperCommander));
  37.     dlog->mCommand = inCommand;
  38.  
  39.     return dlog;
  40. }
  41.  
  42. //----------
  43. #define    RegisterClasses(AbstractClass,AMImpClass,GAImpClass)    \
  44.     RegisterClass_(AbstractClass);    \
  45.     if (useAppearance) {    \
  46.         RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID);    \
  47.     } else {    \
  48.         RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID);    \
  49.     }
  50.  
  51. //----------
  52. void    CAboutDialog::RegisterClass ()
  53. {
  54.     Boolean        useAppearance = UEnvironment::HasFeature (env_HasAppearance);
  55.  
  56.     RegisterClass_(CAboutDialog);
  57.  
  58.     // register the pane classes we use
  59.     RegisterClasses (LPushButton, LAMPushButtonImp, LGAPushButtonImp);
  60.     RegisterClasses (LStaticText, LAMStaticTextImp, LGAStaticTextImp);
  61.  
  62.     sIsRegistered = true;
  63. }
  64.  
  65. //----------
  66. CAboutDialog::CAboutDialog (
  67.     LStream*    inStream)
  68.     : LGADialog (inStream)
  69. {
  70. }
  71.  
  72. //----------
  73. CAboutDialog::~CAboutDialog()
  74. {
  75. }
  76.  
  77. //----------
  78. //    This member function gets called once the containment hierarchy that contains
  79. //    this pane has been built. It gives us a chance to get data members for
  80. //    interesting subviews, and to do other operations now that our subviews exist.
  81. void    CAboutDialog::FinishCreateSelf()
  82. {
  83.     LGADialog::FinishCreateSelf();
  84.  
  85.     mOKButton = (LPushButton*) FindPaneByID ('OK  ');
  86.  
  87.  
  88.     UReanimator::LinkListenerToControls(this, this, RidL_AboutDialogID);
  89.         // the purpose is to "connect" self to whatever controls
  90.         // that we want to "listen" to
  91.  
  92. // any additional initialization for your dialog:
  93.  
  94. }
  95.  
  96. //----------
  97. void    CAboutDialog::DataChanged (
  98.     long        inDataID)
  99. {
  100.     StopListening ();
  101.  
  102.  
  103.     StartListening ();
  104. }
  105.  
  106. //----------
  107. void    CAboutDialog::ListenToMessage (
  108.     MessageT    inMessage,
  109.     void        *ioParam)
  110. {
  111.     switch (inMessage) {
  112.     case msg_OK:
  113.             GetSuperCommander()->ProcessCommand(-mCommand, this);
  114.         break;
  115.  
  116.     case msg_Cancel:
  117.             DoClose();
  118.         break;
  119.  
  120.  
  121.     default:
  122.           ; // do something
  123.         break;
  124.     }
  125. }
  126.  
  127. //----------
  128. Boolean        CAboutDialog::ObeyCommand (
  129.     CommandT    inCommand,
  130.     void*        ioParam)
  131. {
  132.     Boolean        cmdHandled = true;
  133.  
  134.     if (inCommand < 0) {
  135.         // modal dialog has finished
  136.  
  137.         switch (-inCommand) {
  138.         }
  139.  
  140.     } else {
  141.         switch (inCommand) {
  142.  
  143.         default:
  144.                 cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
  145.             break;
  146.         }
  147.     }
  148.  
  149.     return cmdHandled;
  150. }
  151.  
  152. //----------
  153. void    CAboutDialog::FindCommandStatus (
  154.     CommandT    inCommand,
  155.     Boolean        &outEnabled,
  156.     Boolean        &outUsesMark,
  157.     Char16        &outMark,
  158.     Str255        outName)
  159. {
  160.     outUsesMark = false;
  161.  
  162.     switch (inCommand) {
  163.  
  164.     // +++ Add cases here for the commands you handle
  165.  
  166.     default:
  167.             LGADialog::FindCommandStatus(inCommand, outEnabled,
  168.                                             outUsesMark, outMark, outName);
  169.         break;
  170.     }
  171. }
  172.  
  173. // following functions will be obsoleted
  174. // retained only for backwards compatibility
  175.